package utils

import (
	"fmt"
	"gopkg.in/ini.v1"
)

var (
	App_Mode       string
	Http_Port      string
	Db             string
	DbHost         string
	DbPort         string
	DbUser         string
	DbPassword     string
	DbDatabaseName string
)

func init() {
	file, err := ini.Load("D:\\GolandProjects\\ginblog\\config\\config.ini")
	if err != nil {
		fmt.Println("配置文件读取错误，请检查文件路径：", err)
	}
	LoadServer(file)
	LoadData(file)
}

func LoadServer(file *ini.File) {
	App_Mode = file.Section("server").Key("App_Mode").MustString("debug")
	Http_Port = file.Section("server").Key("Http_Port").MustString(":3000")
}

func LoadData(file *ini.File) {
	Db = file.Section("database").Key("Db").MustString("mysql")
	DbHost = file.Section("database").Key("DbHost").MustString("139.159.231.113")
	DbPort = file.Section("database").Key("DbPort").MustString("3306")
	DbUser = file.Section("database").Key("DbUser").MustString("root")
	DbPassword = file.Section("database").Key("DbPassword").MustString("123456")
	DbDatabaseName = file.Section("database").Key("DbDatabaseName").MustString("go")
}
